#include <iostream>

struct student0
{
    uint8_t a;
    uint16_t b;
    uint8_t c;
};

// 字节对齐
struct alignas(2) student
{
    uint8_t a;
    uint16_t b;
    uint8_t c;
};

// int* p[10];  // 数组里面存放的是指针
// int (*p)[10];

int main1(int argc, char const *argv[])
{
    std::cout << sizeof(student0) << "\n";
    std::cout << sizeof(student) << "\n";

    int arry[10] = {};
    // 指针数组
    int *p[10];
    for (int i = 0; i < 10; i++)
    {
        arry[i] = i;
        p[i] = &arry[i];
    }
    for (int i = 0; i < 10; i++)
    {
        std::cout << p[i] << " " << *p[i] << "\n";
    }
    int *lstpaddr = p[9];
    // 未知堆栈信息
    for (int i = 10; i < 20; i++)
    {
        lstpaddr = lstpaddr + 1;
        std::cout << *lstpaddr << " " << lstpaddr << "\n";
    }
    // 数组指针, 指向数组的指针
    int(*p0)[10] = &arry;
    std::cout << (*p0)[5] << "\n";
    std::cout << (*(p0 + 1))[0] << "\n";

    int arr0[10][10];
    for (int i = 0; i < 10; i++)
    {
        for (int j = 0; j < 10; j++)
        {
            arr0[i][j] = i * 10 + j;
            std::cout << i << "->" << j << " " << arr0[i][j] << "\n";
        }
    }
    std::cout << (*(arr0 + 8))[5] << "\n";
    int(*p1)[10] = arr0;
    std::cout << (*p1)[5] << "\n";
    std::cout << (*(p1 + 8))[5] << "\n";

    // int** p2 = arr0;
    // std::cout << (*p2)[5] << "\n";
    // std::cout << (*(p2 + 8))[5] << "\n";
    return 0;
}

#include <string.h>

int main(int argc, char const *argv[])
{
    char p[10] = {'0', '1', '2', '3', '\0', '5', '6', '7', '8', '9'};
    std::cout << p << "\n";
    // sizeof()占用内存大小， strlen以'\01作为结束的长度
    std::cout << sizeof(p) << "\t" << strlen(p) << "\n";
    return 0;
}
